package com.itheima.test1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        //客户端
        //多次发送数据
        //创建连接通道
        Socket socket =new Socket("127.0.0.1",8888);
        //在通道内获取输出流
        OutputStream os = socket.getOutputStream();
        Scanner sc = new Scanner(System.in);
        //发送数据
        while (true){
            System.out.println("请输入要发送的数据：");
            String s = sc.nextLine();
            if ("886".equals(s)){
                break;
            }
            os.write((s+"\n").getBytes());
        }
        //关闭连接通道
        socket.close();
    }
}
